define(['jquery','jquery-ui-modules/widget','loadPlayer',"matchMedia"],function($){'use strict';$.widget('mage.listProductVideoLoader',$.mage.productVideoLoader,{_create:function(){switch(this.element.data('type')){case'youtube':this.element.listVideoYoutube();this._player=this.element.data('mageListVideoYoutube');break;case'vimeo':this.element.listVideoVimeo();this._player=this.element.data('mageListVideoVimeo');break;case'custom':this.element.listVideoCustom();this._player=this.element.data('mageListVideoCustom');break;default:throw{name:'Video Error',message:'Unknown video type',toString:function(){return this.name+': '+this.message;}};}},});$.widget('mage.listVideoYoutube',$.mage.videoYoutube,{_create:function(){var self=this;this._initialize();this.element.append('
');this._on(window,{'youtubeapiready':function(){var host='https://www.youtube.com';if(self.useYoutubeNocookie){host='https://www.youtube-nocookie.com';} if(self._player!==undefined){return;} self._autoplay=true;if(self._autoplay){self._params.autoplay=1;} if(!self._rel){self._params.rel=0;} $.extend(self._params,self._params.youtube);delete self._params.vimeo;delete self._params.youtube;self._player=new window.YT.Player(self.element.children(':first')[0],{height:self._height,width:self._width,videoId:self._code,playerVars:self._params,host:host,events:{'onReady':function onPlayerReady(event){event.target.playVideo();self.onVideoReady();var loaderFull=$(self.element).closest('.fotorama__stage').find('.loader.gallery-fulls-loader');if($('body').hasClass('catalog-product-view')){var videoWrapper=self.element.closest('.fotorama-video-container');videoWrapper.removeClass('still-loading');} if(loaderFull.length!==0){$(loaderFull).fadeOut(400);}},'onStateChange':function(data){var videoWrapper;if($('body').hasClass('catalog-product-view')){videoWrapper=self.element.closest('.fotorama-video-container');if(videoWrapper.length===0){videoWrapper=self.element.closest('.product-video-wrapper');}}else{videoWrapper=self.element.closest('.product-video-wrapper');} switch(window.parseInt(data.data,10)){case 1:self._playing=true;break;default:self._playing=false;break;} self._trigger('statechange',{},data);if((data.data===window.YT.PlayerState.ENDED||data.data===window.YT.PlayerState.UNSTARTED)&&self._loop){self._player.playVideo();} if(data.data===window.YT.PlayerState.PLAYING){videoWrapper.removeClass('still-loading');} if(data.data===window.YT.PlayerState.ENDED&&self._loop){self._player.playVideo();} if(data.data===window.YT.PlayerState.UNSTARTED&&self._loop){self._player.playVideo();}}}});}});this._loadApi();},onVideoReady:function(){this.element.addClass('video-ready');this.element.trigger('videoReady');if(this._autoplay){this._player.playVideo();}},play:function(){if(this._player&&this._player.playVideo){this._super();}},pause:function(){if(this._player&&this._player.pauseVideo){this._super();}},stop:function(){if(this._player&&this._player.stopVideo){this._super();}},destroy:function(){this._super();this.element.empty();this.element.removeClass('video-ready');}});$.widget('mage.listVideoVimeo',$.mage.videoVimeo,{_create:function(){var additionalParams='',src;this._initialize();this._autoplay=true;if(this._autoplay){additionalParams+='&autoplay=1';} if(this._loop){additionalParams+='&loop=1';} if(this._params.vimeo){$.each(Object.keys(this._params.vimeo),function(key,param){additionalParams+='&'+param+'='+this._params.vimeo[param];}.bind(this));} src='https://player.vimeo.com/video/'+ this._code+'?api=1&player_id=vimeo'+ this._code+ additionalParams;let iframe=$('